package com.liu.conversionNumber;

import java.util.Scanner;

public class DecimalToHexadecimal {
    public static void main(String[] args) {
        System.out.println("请输入一个十进制数：");
        Scanner sc = new Scanner(System.in);
        dectohex(sc.nextInt());

    }

    private static void dectohex(int x) {
        if (x < 1){
            return;
        }
        dectohex(x / 16);
        int y = x % 16;
        switch (y){
            case 10: System.out.print(" " + "A");break;
            case 11: System.out.print(" " + "B");break;
            case 12: System.out.print(" " + "C");break;
            case 13: System.out.print(" " + "D");break;
            case 14: System.out.print(" " + "E");break;
            case 15: System.out.print(" " + "F");break;
            default:System.out.print(" " + x % 16);
        }
    }
}
